package leetcode.day_2020_12_21_12_28;

import com.sun.java.swing.plaf.windows.WindowsTextAreaUI;
import sun.awt.image.ImageWatched;

import java.util.LinkedList;
import java.util.Queue;

public class L_225 {
}

class MyStack {
    Queue<Integer> q;
    int top_elem = 0;

    /**
     * 初始化栈
     */
    public MyStack() {
        q = new LinkedList<>();
    }

    /**
     * 入栈
     */
    public void push(int x) {
        q.offer(x);
        top_elem = x;
    }

    /**
     * 出栈
     * @return
     */
    public int pop() {
        int size = q.size();
        while (size >= 1) {
            q.offer(q.poll());
            size -- ;
        }
        // 之前的队尾元素已经到了队头
        return q.poll();
    }

    /**
     * 栈顶
     * @return
     */
    public int top() {
        return top_elem;
    }

    /**
     * 判断栈是否为空
     * @return
     */
    public boolean isEmpty() {
        if(q.isEmpty()) {
            return true;
        }
        return false;
    }
}
